package com.chuanjiabao.wisdom.ui.activity

import android.content.Intent
import android.os.Bundle
import android.view.View
import com.chuanjiabao.wisdom.R
import com.chuanjiabao.wisdom.ui.BaseActivity
import com.chuanjiabao.wisdom.util.ToastUtil
import kotlinx.android.synthetic.main.activity_user_info_phone.*
import kotlinx.android.synthetic.main.activity_user_num_login.etModulePhone
import kotlinx.android.synthetic.main.activity_user_num_login.tvModuleOk

/**
 * 输入手机号码
 */
class UserInfoPhoneActivity : BaseActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_user_info_phone)
        initView()
    }

    private fun initView() {
        ivModuleClose.setOnClickListener(this)
        tvModuleOk.setOnClickListener(this)
    }

    override fun onClick(view: View) {
        when (view.id) {
            R.id.ivModuleClose -> onBackPressed()
            R.id.tvModuleOk -> {
                val phone = etModulePhone.rawText.toString()
                if (phone.isEmpty()) {
                    ToastUtil.showToast("请输入手机号码")
                    return
                }
                if (phone.length != 11) {
                    ToastUtil.showToast("请输入正确的手机号码")
                    return
                }

                val intent = Intent(this, UserInfoCodeActivity::class.java)
                intent.putExtra("module_phone", phone)
                startActivity(intent)
            }
        }
    }

}
